﻿using Client.Constant;
using Client.Framework.Message;
using Client.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Client.Message.Response
{
    [MessageAttr(MessageId.ROLE_LIST)]
    class RoleListResp : ResponseBaseMessage
    {
        public List<ViewRole> Roles { get; } = new List<ViewRole>();
        public int Count { get; set; }

        public override void Deserialize(byte[] buffer)
        {
            RoleList msg = RoleList.Parser.ParseFrom(buffer);
            foreach (var role in msg.Roles)
            {
                ViewRole viewRole = new ViewRole();
                viewRole.ID = role.Id;
                viewRole.RoleName = role.RoleName;
                viewRole.Status = (Enum.DataStatus)role.Status;
                viewRole.Creator = role.Creator;
                viewRole.CreateTime = role.CreateTime;
                viewRole.Updator = role.Updator;
                viewRole.UpdateTime = role.UpdateTime;
                Roles.Add(viewRole);
            }
            Count = msg.Count;
        }
    }
}
